import re
f=open('ysyx_22050920.v','r')
alllines=f.readlines()
f.close()

module_list= ['core','Hazards_ctrl','Reg','toy_cpu','MemBus','cache','sram4K','Fetch','IF_reg','PC','Decode','ID_reg','RegisterFile','CSRsFile','EXE_reg','Execute','IRQ','arithmetic_unit','basediv','basemul','branch_unit','csr_unit','div_unit','load_unit','logic_unit','mul_unit','store_unit','MEM_reg','Memory','Writeback','CoreLocalInterrupt']


f=open('output.v','w+')
for eachline in alllines:
    line = eachline
    for each_module in module_list:
        line=re.sub('module '+each_module,'module ysyx_22050920_'+each_module,line)
        line=re.sub(' '+each_module+' ',' ysyx_22050920_'+each_module+' ',line)

    line=re.sub('module ysyx_22050920_core','module ysyx_22050920',line)
    line=re.sub('h8000_0000','h3000_0000',line)
    f.writelines(line)
f.close()
